#ifndef _NSTAR_HCF4051_H_
#define _NSTAR_HCF4051_H_

#define CHANNEL_OPEN  	1
#define CHANNEL_CLOSE 	0


struct ch_level{
	unsigned char id : 4;
	unsigned char status : 1;
	unsigned char lv : 1;
	unsigned char resever1 : 2;
};

enum NSTAR_HCF4051{
	NSTAR_HCF4051_0,
	NSTAR_HCF4051_1,
	NSTAR_HCF4051_2,
	NSTAR_HCF4051_3,
	NSTAR_HCF4051_4,
	NSTAR_HCF4051_5,
	NSTAR_HCF4051_6,
	NSTAR_HCF4051_7,
	NSTAR_HCF4051_MAX,
};
	
#define NSTAR_HCF4051_DVB   		NSTAR_HCF4051_4
#define NSTAR_HCF4051_MP3   		NSTAR_HCF4051_2
#define NSTAR_HCF4051_INTERPHONE	NSTAR_HCF4051_1
#define NSTAR_HCF4051_LINE1			NSTAR_HCF4051_3
#define NSTAR_HCF4051_LINE2			NSTAR_HCF4051_0
#define NSTAR_HCF4051_MIC			NSTAR_HCF4051_7
#define HCF_CHANLCLOSE              NSTAR_HCF4051_MAX

//数量7 
//优先级 1-7
#define CH1_NB_INTERPHONE  	0
#define CH1_NB_DVB  	1
#define CH1_NB_MP3  	2
#define CH1_NB_MIC  	3
#define CH1_NB_LINE1  	4
#define CH1_NB_LINE2  	5
#define CH_NB_MAX 		6



struct board_ch_level{
	unsigned char validCount;
	struct ch_level level[CH_NB_MAX];
};

void nstar_ch_sel(unsigned char channel, unsigned char sta, unsigned char lv);

#define HCF4051_OPEN_IP(lv) nstar_ch_sel(NSTAR_HCF4051_DVB, 1 , lv)
#define HCF4051_CLOSE_IP() nstar_ch_sel(NSTAR_HCF4051_DVB, 0, 0)

#define HCF4051_OPEN_MP3(lv) nstar_ch_sel(NSTAR_HCF4051_MP3, 1, lv)
#define HCF4051_CLOSE_MP3() nstar_ch_sel(NSTAR_HCF4051_MP3, 0, 0)

#define HCF4051_OPEN_MIC(lv) nstar_ch_sel(NSTAR_HCF4051_MIC, 1, lv)
#define HCF4051_CLOSE_MIC() nstar_ch_sel(NSTAR_HCF4051_MIC, 0, 0)

#define HCF4051_OPEN_LINE1(lv) nstar_ch_sel(NSTAR_HCF4051_LINE1, 1, lv)
#define HCF4051_CLOSE_LINE1() nstar_ch_sel(NSTAR_HCF4051_LINE1, 0, 0)

#define HCF4051_OPEN_LINE2(lv) nstar_ch_sel(NSTAR_HCF4051_LINE2, 1, lv)
#define HCF4051_CLOSE_LINE2() nstar_ch_sel(NSTAR_HCF4051_LINE2, 0, 0)

#define HCF4051_OPEN_INTERPHONE() nstar_ch_sel(NSTAR_HCF4051_INTERPHONE, 1, 1)
#define HCF4051_CLOSE_INTERPHONE() nstar_ch_sel(NSTAR_HCF4051_INTERPHONE, 0, 0)

#define HCF4051_CLOSE() nstar_ch_sel(HCF_CHANLCLOSE, 0, 0)



#define PANEL_SEL_MP3(lv)   nstar_ch_close_sel(NSTAR_HCF4051_MP3, 1, lv)
#define PANEL_SEL_MIC(lv)   nstar_ch_close_sel(NSTAR_HCF4051_MIC, 1, lv)
#define PANEL_SEL_LINE1(lv) nstar_ch_close_sel(NSTAR_HCF4051_LINE1, 1, lv)
#define PANEL_SEL_LINE2(lv) nstar_ch_close_sel(NSTAR_HCF4051_LINE2, 1, lv)
#define PANEL_SEL_NONE()    nstar_ch_close_sel(HCF_CHANLCLOSE, 0, 0)




unsigned char visit_ch_sel(void);
void board_ch_init(void);


#endif //_NSTAR_HCF4051_H_
